package com.ys.servers.common.content;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import io.vertx.core.json.JsonObject;

/**
 * Created by taotao on 2017/2/24.
 */
public abstract class ContentEntity {

    @JSONField(name = "_id")
    private String id;

    public ContentEntity() {
    }

    public JsonObject toDataObject() {
        return new JsonObject(JSON.toJSONString(this));
    }

    public static <T> T parseJsonObject(JsonObject dataObject, Class<T> clazz) {
        return JSON.parseObject(dataObject.encode(), clazz);
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }


    public static <T> T parseString(String jsonString, Class<T> clazz) {
        return JSON.parseObject(jsonString, clazz);
    }

    public String toString() {
        return JSON.toJSONString(this);
    }
}
